<?php

namespace App\Http\Controllers\Api;

use App\Models\Team;
use App\Models\User;
use Illuminate\Http\Request;

class TeamController extends ApiController
{
    private $uid = '';


    public function __construct(Request $request)
    {
        $this->uid = auth('api')->id();
    }

    //球队列表
    public function getTeamList(Request $request){
        $tea = new Team();
        $page = isset($request['page']) ? $request['page'] : 1;
        $pageSize = isset($request['pageSize']) ? $request['pageSize'] : 15;
        $data = $tea->getTeamList($page,$pageSize) ?? '';
        return self::returnAjax(['list'=>$data], 200, "球队风采");
    }

    //球队详情
    public function getTeamDetail(Request $request){
        $id    =$request['id'];
        $tea = new Team();
        $data = $tea->getDetail($id) ?? '';
        return self::returnAjax($data, 200, "球队详情");
    }

    //当前球队成员
    public function getPlayers(Request $request){
        $team_id =$request['id'];
        $img = User::where('team_Id',$team_id)->select('user_headimgurl','id')->get();
        return self::returnAjax(['list'=>$img], 200, "球队详情");
    }




}
